@extends('generalAdmin.general-admin-layouts')
@section('style')
    <meta name="_token" content="{{ csrf_token() }}"/>
    <style>
        .staff-th{
            text-align: center;
            color: #676767;
        }
        .staff-td{
            text-align: center;
            color: #676767;
        }
    </style>
    <link rel="stylesheet" href="{{asset('admin_assets/css/bootstrap-datetimepicker.min.css')}}">
    <link rel="stylesheet" href="{{url('css/search.css')}}">
@stop
@section('content')
    <div class="content-wrapper" style="background-color: white">
        <section id="list" class="content">
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="box box-info"
                         style="padding-top: 0px;margin-top: 0px;border-top: 0px;border-bottom: solid 1px #0080ff;">
                        <div class="box-body" style="">
                            <div class="row">
                                <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12" style="margin-top: 1%">
                                    <a href="{{url('generalAdmin/index')}}" title="返回首页" style="float: left"><i class="fa fa-home fa-2x"
                                                                                                                style="width: 100%;color: #009aff">
                                        </i></a>
                                    <a href="{{url('generalAdmin/staff')}}"><span style="font-size: 20px;float: left;color: #009aff">&nbsp;员工管理</span></a>
                                    <div class="clear"></div>
                                </div>
                                {{--<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12 col-lg-offset-6 col-md-offset-4 btn-div">--}}
                                    {{--<button type="button" class="btn btn-info div-btn" data-toggle="modal" data-target="#admin-add-userModal" style="background: #009aff;float: right;margin-left: 1%;margin-top: 1%">添加员工</button>--}}
                                    {{--<form action="{{url('generalAdmin/staffSearch')}}" method="post" enctype="multipart/form-staff" class="search">--}}
                                        {{--{{csrf_field()}}--}}
                                        {{--<button class="fa fa-search fa-lg"></button>--}}
                                        {{--<input type="search" class="search" value="{{$keywords}}" id="search-input" name="search">--}}
                                    {{--</form>--}}
                                {{--</div>--}}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            @include('public/alert')
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th class="staff-th">#</th>
                                <th class="staff-th">部门</th>
                                <th class="staff-th">职务</th>
                                <th class="staff-th">姓名</th>
                                <th class="staff-th">用户名</th>
                                <th class="staff-th">电话</th>
                                <th class="staff-th">身份证号</th>
                                <th class="staff-th">邮箱</th>
                                <th class="staff-th">入职时间</th>
                                <th class="staff-th">操作</th>
                            </tr>
                            </thead>
                            <tbody class="list">
                            @if($staff->isEmpty())
                                <tr>
                                    <td colspan="9" style="text-align: center;color: #676767">暂无数据</td>
                                </tr>
                            @else
                                @foreach($staff as $k=>$v)
                                    <tr>
                                        <td class="staff-td">{{$k+1}}</td>
                                        <td class="staff-td type">{{config('config.admin_role')[$v['type']]}}</td>
                                        <td class="staff-td duty">{{$v['duty']}}</td>
                                        <td class="staff-td real_name">{{$v['real_name']}}</td>
                                        <td class="staff-td name">{{$v['account']}}</td>
                                        <td class="staff-td phone">{{$v['phone']}}</td>
                                        <td class="staff-td certificate_number">{{$v['certificate_number']}}</td>
                                        <td class="staff-td email">{{$v['email']}}</td>
                                        <td class="staff-td hiredate">{{$v['hiredate']}}</td>
                                        <td class="staff-td">
                                            <a href="{{url('Admin/generalAdmin/del_staff',['id'=>$v['id']])}}" onclick="return confirm('确定要删除吗?')">删除</a>
                                            <a href="#" class="p" sid="{{$v['id']}}" type="{{$v['type']}}"
                                               duty="{{$v['duty']}}" real_name="{{$v['real_name']}}" phone="{{$v['phone']}}"
                                               certificate_number="{{$v['certificate_number']}}" email="{{$v['email']}}"
                                               hiredate="{{$v['hiredate']}}" data-toggle="modal" data-target="#admin-edit-userModal">修改</a>
                                            <a href="{{url('Admin/generalAdmin/reset_pwd',['id'=>$v['id']])}}" onclick="return confirm('密码重置后为初始密码123456')">重置密码</a>
                                        </td>
                                    </tr>
                                @endforeach
                            @endif
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </section>
    </div>
    @include('public/admin-edit-userModal')
    @include('public/admin-add-userModal')
@stop
@section('javascript')
    <script src="{{asset('admin_assets/js/bootstrap-datetimepicker.min.js')}}"></script>
    <script src="{{asset('js/ip.js')}}"></script>
    <script src="{{asset('js/list.min.js')}}"></script>
    <script>
        var options = {
            valueNames: ['type', 'duty','real_name','name','phone','certificate_number','email','hiredate']
        };
        var List = new List('list', options);
        List.search($('#search-input').val());
        $(".form_datetime").datetimepicker({
            format: "yyyy-mm-dd hh:ii:ss",
            autoclose: true,
            todayBtn: true,
            minuteStep: 10,
            language: "en"
        });
        $(".p").click(function () {
            var department=$(this).attr('type');
            $("#hide_id").val($(this).attr('sid'));
            $("#department").val(department);
            $("#post").val($(this).attr('duty'));
            $("#name").val($(this).attr('real_name'));
            $("#tel").val($(this).attr('phone'));
            $("#card").val($(this).attr('certificate_number'));
            $("#email").val($(this).attr('email'));
            $("#apply_date").val($(this).attr('hiredate'));
        });
    </script>
@stop
